home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*
- * rminfo.c --
- *
- * This is a simple RPC client program to retrieve real memory usage
- * information from a host running IRIX that has rpc.rminfod installed.
- *
- * usage: rminfo host1 [host2 ...]
- */
-
- #include <stdio.h>
- #include <rpc/rpc.h>
- #include <sys/param.h>
- #define _RPCGEN_CLNT
- #include "rminfo.h"
-
- /*
- * pprint --
- *
- * Print values in terms of kilobytes or megabytes, if possible.
- */
-
- #define MAXKBUF 20
- #define kilo 1024
- #define mega (kilo*kilo)
-
- static void
- pprint(char *lab, long val)
- {
- if (val >= mega)
- printf("%s%.1fM", lab, ((float)val) / mega);
- else if (val >= kilo)
- printf("%s%.1fK", lab, ((float)val) / kilo);
- else
- printf("%s%d", lab, val);
- }
-
- main(int argc, char **argv)
- {
- char *srv;
- CLIENT *clnt;
- rminfo1 *rm;
-
- while (argc-- > 1) {
- srv = *++argv;
-
- /*
- * Once the client handle is created, get the info from the server.
- */
- clnt = clnt_create(srv, RMINFOPROG, RMINFOVERS, "udp");
- if (clnt == NULL) {
- fprintf(stderr, "rminfo: %s", clnt_spcreateerror(srv));
- continue;
- }
-
- rm = rminfoproc_get_1(NULL, clnt);
- if (rm == NULL) {
- fprintf(stderr, "rminfo: %s", clnt_sperror(clnt, srv));
- continue;
- }
- clnt_destroy(clnt);
-
- pprint("phys ", rm->physmem);
- pprint(", buf ", rm->bufmem);
- pprint(", free ", rm->freemem);
- pprint(", avails ", rm->availsmem);
- pprint(", availr ", rm->availrmem);
- pprint(", delwri ", rm->delwri);
- putchar('\n');
- }
- }
-